package com.example.springsecuritydemo.controller;

import com.example.springsecuritydemo.config.ResponseResult;
import com.example.springsecuritydemo.pojo.User;
import com.example.springsecuritydemo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: LoginController
 * @Descripiton: TODO
 * @Author: 小郑
 * @Date： 2023/10/29 8:35
 * @Version：1.8
 **/
@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 登录
     * @param user
     * @return {@link ResponseResult}
     */
    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user) {
        return loginService.login(user);
    }


    @RequestMapping("/user/logout")
    public ResponseResult logOut(){
        return loginService.logOut();
    }
}